From: Claudio Cambra Date: Fri, 14 Mar 2025 13:10:18 +0000 (+0800) Subject: gui/macOS: Avoid UB in edge cases where there is no matching account state for a... X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~18^2^2~7^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b26d74146b10c6021a781631a236f3b415c42370;p=nextcloud-desktop.git gui/macOS: Avoid UB in edge cases where there is no matching account state for a domain Do not assume existence of an account for a given domain identifier -- users can modify the config in unexpected ways Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileproviderdomainmanager_mac.mm b/src/gui/macOS/fileproviderdomainmanager_mac.mm index 7af19491d..233d5adac 100644 --- a/src/gui/macOS/fileproviderdomainmanager_mac.mm +++ b/src/gui/macOS/fileproviderdomainmanager_mac.mm @@ -27,6 +27,12 @@ #include "gui/accountmanager.h" #include "libsync/account.h" +namespace OCC { + +Q_LOGGING_CATEGORY(lcMacFileProviderDomainManager, "nextcloud.gui.macfileproviderdomainmanager", QtInfoMsg) + +} + // Ensure that conversion to/from domain identifiers and display names // are consistent throughout these classes namespace { @@ -118,7 +124,8 @@ QString accountIdFromDomainId(NSString * const domainId) return account->userIdAtHostWithPort(); } } - Q_UNREACHABLE(); + qCWarning(OCC::lcMacFileProviderDomainManager) << "Could not find account id for domain id:" << qDomainId; + return {}; } API_AVAILABLE(macos(11.0)) @@ -131,8 +138,6 @@ inline QString accountIdFromDomain(NSFileProviderDomain * const domain) namespace OCC { -Q_LOGGING_CATEGORY(lcMacFileProviderDomainManager, "nextcloud.gui.macfileproviderdomainmanager", QtInfoMsg) - namespace Mac { class API_AVAILABLE(macos(11.0)) FileProviderDomainManager::MacImplementation